import { MockMethod } from 'vite-plugin-mock';
import Mock from 'mockjs';

export default [
  {
    url: '/api/user/login',
    method: 'post',
    response: () => ({
      code: '000',
      data: {
        ...Mock.mock({
          name: 'td_main',
          roles: ['ALL_ROUTERS'],
          access_token: 'ewrwfsdlfkslfkdlskflsdfklsdkfls',
        }),
      },
    }),
  },
  {
    url: '/api/user/get_current_user_info',
    method: 'get',
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          msg: 'td_main',
          data: {
            username: '@natural(0, 20)',
            real_name: '@cname()',
            email: '@email',
            create_time: '2024-05-18 @date("HH:mm:ss")',
            last_login_time: '2024-05-18 @date("HH:mm:ss")',
          }
        }),
      },
    }),
  },
  {
    url: '/api/get-purchase-list',
    method: 'get',
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          'list|1-100': [
            {
              index: /S20201228115950[0-9][0-9][0-9]/,
              pdName: 'Macbook',
              pdNum: 'p_tmp_60a637cd0d',
              'purchaseNum|1-100': 100,
              adminName: '财务部111',
              updateTime: '2020-05-20@date("HH:mm:ss")',
              pdType: '电子产品',
            },
            {
              index: /S20201228115950[0-9][0-9][0-9]/,
              pdName: 'Macbook',
              pdNum: 'p_tmp_60a637cd0d',
              'purchaseNum|1-100': 100,
              adminName: '财务部',
              updateTime: '2020-05-20@date("HH:mm:ss")',
            },
          ],
        }),
      },
    }),
  },
  {
    url: '/api/performance/chain/config/list',
    method: 'get',
    params: { params: { page: 1, per_page: 60 } },
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          'list|1-100': [
            {
              'index|+1': 1,
              'status|1': '@natural(0, 2)',
              version: 'V3.0.@natural(01, 10)',
              name: '区块链@natural(0, 100)',
              'authType|1': '@natural(1, 2)',
              'consensus_type|1': '@natural(0, 2)',
              updateTime: '2020-05-30 @date("HH:mm:ss")',
              hash_type: () => {
                const options = ['SHA256', 'SM3'];
                return options[Math.floor(Math.random() * options.length)];
              },
              adminName: '@cname()',
            },
          ],
        }),
      },
    }),
  },
  {
    url: '/api/request/get-list',
    method: 'get',
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          'list|1-10': [
            {
              'index|+1': 1,
              id: 'request@natural(0, 20)',
              'status|1': '@natural(0, 2)',
              version: 'V3.0.@natural(01, 10)',
              chain_name: '区块链@natural(0, 100)',
              request_name: '@natural(0, 100)请求',
              testplan_name: 'Docker_Go@natural(01, 10)',
              contr_name: 'Docker_save@natural(01, 10)',
              contr_type: 'save',
              creator: '@cname()',
              'authType|1': '@natural(1, 2)',
              'consensus_type|1': '@natural(0, 2)',
              start_time: '2024-05-18 @date("HH:mm:ss")',
              custom_type: ['go-sdk', 'java-sdk'],
              hashType: () => {
                const options = ['SHA256', 'SM3'];
                return options[Math.floor(Math.random() * options.length)];
              },
              adminName: '@cname()',
            },
          ],
        }),
      },
    }),
  },
  {
    url: '/api/scene/get-list',
    method: 'get',
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          'list|1-10': [
            {
              'index|+1': 1,
              id: 'request@natural(0, 20)',
              'status|1': '@natural(0, 2)',
              version: 'V3.0.@natural(01, 10)',
              scene_name: '@natural(0, 100)场景',
              scene1: 'save_@natural(0, 100)k',
              scene2: '@natural(0, 50)',
              scene3: '@natural(0, 1000)',
              scene4: '@natural(0, 10)',
              contr_type: 'save',
              creator: '@cname()',
              'authType|1': '@natural(1, 2)',
              'consensus_type|1': '@natural(0, 2)',
              start_time: '05-18 @date("HH:mm:ss")',
              custom_type: ['go-sdk', 'java-sdk'],
              hashType: () => {
                const options = ['SHA256', 'SM3'];
                return options[Math.floor(Math.random() * options.length)];
              },
              adminName: '@cname()',
            },
          ],
        }),
      },
    }),
  },
  {
    url: '/register/chains/upload',
    method: 'post',
    timeout: 2000,
    response: {
      code: 0,
      data: {
        name: 'vben',
      },
    },
  },

  {
    url: '/api/query/chains_conn_list/test',
    method: 'get',
    response: {
      code: 0,
      data: {
        ...Mock.mock({
          'list|1-10': [
            // {
            //   'index|+1': 1,
            //   chain_id: 'chain@natural(0, 20)',
            //   chain_name: '@cname()的测试链',
            //   host_num: '@natural(0, 20)',
            //   node_num: '@natural(0, 100)',
            //   "node_list": [
            //     {"node_name":"node1", "node_ipaddr":"130.0.0.1:8081"},
            //     {"node_name":"node2", "node_ipaddr":"81.127.12.11:8081"},
            //     {"node_name":"node3", "node_ipaddr":"172.127.12.11:8081"}
            //   ],
            //   'con_state|1': '@natural(0, 2)',
            //   'auth_type|1': '@natural(0, 2)',
            //   'crypto_hash|1': '@natural(0, 1)',
            //   "crypto_config":"/data/crypto-config.zip",
            //   create_time: '2023-07-07 @date("HH:mm:ss")',
            //   create_user: '@cname()',
            // },
            {
              'value|+1': 1,
              label: '@cname()的测试链',
              children: [
                { label: 'node1:110.0.0.1:8081', value: '110.0.0.1:8081' },
                { label: 'node2:110.0.0.1:8081', value: '120.0.0.1:8081' },
                { label: 'node3:110.0.0.1:8081', value: '130.0.0.1:8081' },
              ],
            },
          ],
        }),
      },
    },
  },

  {
    url: '/api/query/chains_conn_list',
    method: 'get',
    response: {
      code: 0,
      data: {
        ...Mock.mock({
          'list|1-10': [
            {
              'index|+1': 1,
              chain_id: 'chain@natural(0, 20)',
              chain_name: '@cname()的测试链',
              host_num: '@natural(0, 20)',
              node_num: '@natural(0, 100)',
              node_list: [
                { node_name: 'node1', node_ipaddr: '130.0.0.1:8081' },
                { node_name: 'node2', node_ipaddr: '81.127.12.11:8081' },
                { node_name: 'node3', node_ipaddr: '172.127.12.11:8081' },
              ],
              'con_state|1': '@natural(0, 2)',
              'auth_type|1': '@natural(0, 2)',
              'crypto_hash|1': '@natural(0, 1)',
              crypto_config: '/data/crypto-config.zip',
              create_time: '2023-07-07 @date("HH:mm:ss")',
              create_user: '@cname()',
            },
          ],
        }),
      },
    },
  },

  {
    url: '/api/query/chains_conn',
    method: 'get',
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          'list|1-200': [
            {
              'index|+1': 1,
              chain_id: 'chain@natural(0, 20)',
              chain_name: '@cname()的测试链',
              host_num: '@natural(0, 20)',
              node_num: '@natural(0, 100)',
              node_list: [
                { node_name: 'node1', node_ipaddr: '130.0.0.1:8081' },
                { node_name: 'node2', node_ipaddr: '81.127.12.11:8081' },
                { node_name: 'node3', node_ipaddr: '172.127.12.11:8081' },
              ],
              'con_state|1': '@natural(0, 2)',
              'auth_type|1': '@natural(0, 2)',
              'crypto_hash|1': '@natural(0, 1)',
              crypto_config: '/data/crypto-config.zip',
              create_time: '2023-07-07 @date("HH:mm:ss")',
              create_user: '@cname()',
            },
          ],
        }),
      },
    }),
  },

  {
    url: '/api/operate/chains_conn',
    method: 'post',
    // data: {"ids": [''], "param": {}, "op_type": 4},
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          data: {
            status: 'success',
            files: [{ url: '/data/crypto-config.zip', name: 'crypto-config.zip' }],
            create_time: '2023-07-07 @date("HH:mm:ss")',
            create_user: '@cname()',
          },
        }),
      },
    }),
  },

  {
    url: '/api/operate/chains_conn/run',
    method: 'post',
    // data: {"ids": [''], "param": {}, "op_type": 4},
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          data: {
            code: '532',
            msg: '部分失败，请查看失败原因',
            'last_status|1': '@natural(0, 2)',
            fail_node: [{ node_name: 'node1', node_ipaddr: '130.0.0.1:8081' }],
            create_time: '2023-07-07 @date("HH:mm:ss")',
            create_user: '@cname()',
          },
        }),
      },
    }),
  },

  {
    // url: '/funtest/testcase',
    url: '/api/query/testcase_list',
    method: 'get',
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          'list|1-200': [
            {
              'id|+1': 1,
              'index|+1': 1,
              testcase_name: '@cname()的测试用例',
              testcase_tags: ['v3环境', '性能测试', 'xx专用'],
              'module|1': '@natural(0, 5)',
              testcase_version: 'V@natural(200, 210)',
              'priority|1': '@natural(0, 3)',
              'last_status|1': '@natural(0, 3)',
              git_addr: 'http://git.code.tencent.com/testcase',
              create_time: '2023-07-07 @date("HH:mm:ss")',
              create_user: '@cname()',
            },
          ],
        }),
      },
    }),
  },

  {
    // url: '/funtest/testcase',
    url: '/api/query/testcase_info',
    method: 'get',
    data: { testcase_id: '1' },
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          data: {
            id: 1,
            testcase_name: '张三测试用例',
            testcase_tags: { '1': 'v3环境', '2': '性能测试', '3': 'xx专用' },
            module: '1',
            testcase_version: 'V300',
            priority: '1',
            last_status: '1',
            git_addr: 'http://git.code.tencent.com/testcase',
            create_time: '2023-07-07 @date("HH:mm:ss")',
            create_user: '@cname()',
          },
        }),
      },
    }),
  },

  {
    // url: '/funtest/testcase',
    url: '/api/operate/testcase',
    method: 'post',
    data: { ids: ['1'], param: {}, op_type: '0' },
    response: () => ({
      code: '000',
      data: {
        ...Mock.mock({
          data: {
            code: 0,
            msg: "删除测试用例id为 ['string'] 的用例信息成功",
            data: {},
          },
        }),
      },
    }),
  },

  {
    url: '/api/detail-basic',
    method: 'get',
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          name: 'td_20023747',
          loginType: 'Web',
          currentRole: 'Admin',
          rightsList: '通用权限',
          userStatus: '启用',
          language: '简体中文',
          timeZone: '(GMT+08:00)中国时区—北京（Asia/Beijing）',
        }),
      },
    }),
  },
  {
    url: '/api/get-card-list',
    method: 'get',
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          'list|48-50': [
            {
              'index|+1': 1,
              isSetup: '@boolean',
              'type|1': '@natural(1, 5)',
              'banner|1': [
                'https://tdesign.gtimg.com/starter/cloud-db.jpg',
                'https://tdesign.gtimg.com/starter/cloud-server.jpg',
                'https://tdesign.gtimg.com/starter/ssl.jpg',
                'https://tdesign.gtimg.com/starter/t-sec.jpg',
                'https://tdesign.gtimg.com/starter/face-recognition.jpg',
              ],
              'name|1': ['人脸识别', 'SSL证书', 'CVM', '云数据库', 'T-Sec 云防火墙'],
              'description|1': [
                '基于腾讯优图强大的面部分析技术，提供包括人脸检测与分析、五官定位、人脸搜索、人脸比对、人脸',
                '云硬盘为您提供用于CVM的持久性数据块级存储服务。云硬盘中的数据自动地可用区内以多副本冗',
                'SSL证书又叫服务器证书，腾讯云为您提供证书的一站式服务，包括免费、付费证书的申请、管理及部',
                '腾讯安全云防火墙产品，是腾讯云安全团队结合云原生的优势，自主研发的SaaS化防火墙产品，无需客无需客无需客无需客无需客无需客无需客',
                '云数据库MySQL为用户提供安全可靠，性能卓越、易于维护的企业级云数据库服务。',
              ],
            },
          ],
        }),
      },
    }),
  },
  {
    url: '/api/get-project-list',
    method: 'get',
    response: () => ({
      code: 0,
      data: {
        ...Mock.mock({
          'list|1-50': [
            {
              'index|+1': 1,
              adminPhone: '+86 13587609955',
              updateTime: '2020-05-30 @date("HH:mm:ss")',
              'adminName|1': ['顾娟	', '常刚', '郑洋'],
              'name|1': [
                '沧州市办公用品采购项目',
                '红河哈尼族彝族自治州办公用品采购项目	',
                '铜川市办公用品采购项目',
                '陇南市办公用品采购项目	',
                '六安市办公用品采购项目	 ',
              ],
            },
          ],
        }),
      },
    }),
  },
  {
    url: '/api/post',
    method: 'post',
    timeout: 200000,
    response: {
      code: 0,
      data: {
        name: 'vben',
      },
    },
  },
  {
    url: '/api/performance/chain/config/create',
    method: 'post',
    response: () => ({
      code: '000',
      data: {
        ...Mock.mock({
          name: 'create_chain_config',
        }),
      },
    }),
  },
] as MockMethod[];
